package com.example.qxfw.yjqx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.qx.TownshipStation;
import com.example.qxfw.common.entity.zy.CcshxImpDot;
import com.example.qxfw.cshx.service.CcshxImpDotService;
import com.example.qxfw.ybzz.service.TownshipStationService;
import com.example.qxfw.yjqx.service.ImpGoalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "应急气象-重要目标")
@RestController
@CrossOrigin
@RequestMapping("/zymbController")
public class ZymbController {

    @Autowired
    private ImpGoalService impGoalService;

    @Autowired
    private TownshipStationService townshipStationService;

    @Autowired
    private CcshxImpDotService ccshxImpDotService;

    @ApiOperation("获取关联站点")
    @GetMapping("/getTownship")
    public SysResult getaTownship(String city){
        List<TownshipStation> list = townshipStationService.getList2(city);
        return SysResult.success(list);
    }

    @ApiOperation("查询重要目标")
    @GetMapping("/getCshxImpDot")
    public SysResult getCshxImpDot(String name){
        List<CcshxImpDot> list = ccshxImpDotService.getList1(name);
        return SysResult.success(list);
    }

    @ApiOperation("查询重要目标")
    @GetMapping("/getCshxImpDot1")
    public SysResult getCshxImpDot1(){
        List<CcshxImpDot> list = ccshxImpDotService.getList2();
        return SysResult.success(list);
    }

    @ApiOperation("添加重要目标")
    @PostMapping("/saveCshxImpDot")
    public SysResult saveCshxImpDot(@RequestBody  CcshxImpDot ccshxImpDot ){
        Integer rows = ccshxImpDotService.save(ccshxImpDot);
        return SysResult.success(rows);
    }

    @ApiOperation("修改重要目标")
    @PostMapping("/updateCshxImpDot")
    public SysResult updateCshxImpDot(@RequestBody CcshxImpDot ccshxImpDot){
        Integer rows = ccshxImpDotService.update(ccshxImpDot);
        return SysResult.success(rows);
    }

    @ApiOperation("删除重要目标")
    @GetMapping("/deleteCshxImpDot")
    public SysResult deleteCshxImpDot(String id){
        Integer rows = ccshxImpDotService.delete(id);
        return SysResult.success(rows);
    }

    @ApiOperation("获取站点信息")
    @GetMapping("/getTownship1")
    public SysResult getTownship1(String jd,String wd,String city){
        List<TownshipStation> list = townshipStationService.getList(jd, wd, city);
        return SysResult.success(list);
    }

//
//    @ApiOperation("查询重要目标")
//    @GetMapping("/getImpGoal")
//    public SysResult getImpGoal(String targetName, String targetType, String principalName){
//        List<ImpGoal> list = impGoalService.getList(targetName, targetType, principalName);
//        return SysResult.success(list);
//    }
//
//    @ApiOperation("查询重要目标")
//    @GetMapping("/getImpDoal1")
//    public SysResult getImpGoal1(){
//        List<ImpGoal> list = impGoalService.getList1();
//        return SysResult.success(list);
//    }
}
